function getHistoryAddress(){
	showDefault("loading","加载中...");
	var jsonstr = "filterscount=0&groupscount=0&pagenum=0&pagesize=10&recordstartindex=0&recordendindex=10&iphone="+getCookie("useriphone")+"&addressLike=";
	$.ajax({
		cache: false,
		type: "post",
		datatype: 'json',
		contentType: 'application/json;charset=UTF-8',
		data: jsonstr,
		url: ''+httpipstr+'alfa-mobile-ws/rest/historyaddress/findlist?mobiletoken='+getCookie("mobiletokenuser")+'',
		success: function(data) {
			toast.hide();
			var str="";
			if(data.total=="0"){
				$("#addressstr").html("暂无收油地址请添加");
			}else{
				if(getCookie("recycleaddress")==""){
					setcookie("recycleaddress", data.rows[0].address, 30, "/");
					setcookie("recycleaddressid", data.rows[0].id, 30, "/");
					setcookie("recycleaddressiphone", data.rows[0].iphone, 30, "/");
				}else{
				}
				$("#realname").html("售油人："+""+getCookie("realname")+"")
				$("#addressstr").html("收油地址:"+""+getCookie("recycleaddress")+"");
				$("#iphone").val(getCookie("recycleaddressiphone"));
			}
		}
	})
}
function insertorders(){
	var remark=$("#textarea").val();
	var num=$("#num").val();
	var iphone=$("#iphone").val();
	var address=getCookie("recycleaddress");
	var iphonetype=true;
	var addresstype=true;
	if(num.toString().length>5 ){
		iphonetype=false;
		showDefault("fail","请输入有效的桶数");
	}
	 if(!num.match(/^(([0-9]+\.[0-9]*[1-9][0-9]*)|([0-9]*[1-9][0-9]*\.[0-9]+)|([0-9]*[1-9][0-9]*))$/ )||num=="0"){
		iphonetype=false;
		showDefault("fail","请输入有效的桶数");
	}
	 if(iphone==""){
		iphonetype=false;
		showDefault("fail","请输入联系方式");
	} if(address==""){
		addresstype=false;
		showDefault("fail","请添加地址");
	} if(!iphone.match(/^1[34578]\d{9}$/)) {
		iphonetype=false;
		showDefault("fail","输入有效的手机号");
	}
	else if(iphonetype&&addresstype){
		showDefault("loading","加载中...");
		var json={"username":""+getCookie("realname")+"","iphone":""+getCookie("useriphone")+"","address":""+address+"","num":""+num+"","orgname":""+getCookie("orgname")+"","orgstatus":"1","remark":""+(!remark ||remark=="undefined"? "" : ""+remark+"")+"","isSms":"0","xphone":""+iphone+""};
		$.ajax({
			type: "post",
			datatype: 'json',
			contentType: 'application/json;charset=UTF-8',
			url: ''+httpipstr+'alfa-mobile-ws/rest/order/insertorders?mobiletoken='+getCookie("mobiletokenuser")+'',
			data: JSON.stringify(json),
			success: function(data) {
				if(data.message=="1"){
					var requestpath=$("#requestpath").val();
					var json1 = {
							"openid": ""+getCookie("openid")+"",
						}
					$.ajax({
						type: "post",
						datatype: 'json',
						contentType: 'application/x-www-form-urlencoded;charset=UTF-8',
						url: 'http://tugo.cn/weixin_aef/recycle/TextToUser',
						data: JSON.stringify(json1),
						success: function(data) {
							if(data.code=="0"){
								toast.hide();
								var jsonstr = "roleId=27";
								$.ajax({
									cache: false,
									type: "post",
									datatype: 'json',
									contentType: 'application/json;charset=UTF-8',
									data: jsonstr,
									url: 'http://118.178.18.0:8082/alfa-mobile-ws/rest/OpenId/findlist?mobiletoken='+getCookie("mobiletokenuser")+'',
									success: function(data) {
										 $.each( data.rows, function(index, content){ 
											 timenow()
											 var json2={"openid":""+content.openid+"","time":""+ timenow()+"","name":""+getCookie("realname")+""}
										$.ajax({
											cache: false,
											type: "post",
											datatype: 'json',
											contentType: 'application/json;charset=UTF-8',
											url: 'http://tugo.cn/weixin_aef/recycle/TextToAdmin',
											data: JSON.stringify(json2),
											success: function(data) {
												if(data.errcode=="0"){
													toast.hide();
													location.href="user_functionStatus.jsp"
												}
												}
										})
										});
									}
									})
							}
						}
					})
					
				}else if(data.message=="2"){
					showDefault("fail","插入订单失败，请重试");
				}else if(data.message=="3"){
					showDefault("fail","当天的订单总数超出最大数量限制，请明天再发起收油");
				}
			}})
	}
}
/**
 * 
 * 获取当前时间
 */
function p(s) {
    return s < 10 ? '0' + s: s;
}
function timenow() {
var myDate = new Date();
//获取当前年
var year=myDate.getFullYear();
//获取当前月
var month=myDate.getMonth()+1;
//获取当前日
var date=myDate.getDate(); 
var h=myDate.getHours();       //获取当前小时数(0-23)
var m=myDate.getMinutes();     //获取当前分钟数(0-59)
var s=myDate.getSeconds();  

var now=year+'-'+p(month)+"-"+p(date)+" "+p(h)+':'+p(m)+":"+p(s);
return now;
}